<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module Zlib - zlib: Ruby Standard Library Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#module-Zlib-label-Sample+usage">Sample usage</a>
    <li><a href="#module-Zlib-label-Class+tree">Class tree</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-adler32">::adler32</a>
    <li ><a href="#method-c-adler32_combine">::adler32_combine</a>
    <li ><a href="#method-c-crc32">::crc32</a>
    <li ><a href="#method-c-crc32_combine">::crc32_combine</a>
    <li ><a href="#method-c-crc_table">::crc_table</a>
    <li ><a href="#method-c-deflate">::deflate</a>
    <li ><a href="#method-c-gunzip">::gunzip</a>
    <li ><a href="#method-c-gzip">::gzip</a>
    <li ><a href="#method-c-inflate">::inflate</a>
    <li ><a href="#method-c-zlib_version">::zlib_version</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-Zlib">
    <h1 id="module-Zlib" class="module">
      module Zlib
    </h1>

    <section class="description">
    
<p>This module provides access to the <a href="http://zlib.net">zlib library</a>. <a href="Zlib.html"><code>Zlib</code></a> is designed to be a portable, free, general-purpose, legally unencumbered – that is, not covered by any patents – lossless data-compression library for use on virtually any computer hardware and operating system.</p>

<p>The zlib compression library provides in-memory compression and decompression functions, including integrity checks of the uncompressed data.</p>

<p>The zlib compressed data format is described in RFC 1950, which is a wrapper around a deflate stream which is described in RFC 1951.</p>

<p>The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of IO. The gzip format is described in RFC 1952 which is also a wrapper around a deflate stream.</p>

<p>The zlib format was designed to be compact and fast for use in memory and on communications channels. The gzip format was designed for single-file compression on file systems, has a larger header than zlib to maintain directory information, and uses a different, slower check method than zlib.</p>

<p>See your system’s zlib.h for further information about zlib</p>

<h2 id="module-Zlib-label-Sample+usage">Sample usage<span><a href="#module-Zlib-label-Sample+usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Using the wrapper to compress strings with default parameters is quite simple:</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&quot;zlib&quot;</span>

<span class="ruby-identifier">data_to_compress</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&quot;don_quixote.txt&quot;</span>)

<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Input size: #{data_to_compress.size}&quot;</span>
<span class="ruby-comment">#=&gt; Input size: 2347740</span>

<span class="ruby-identifier">data_compressed</span> = <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">Deflate</span>.<span class="ruby-identifier">deflate</span>(<span class="ruby-identifier">data_to_compress</span>)

<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Compressed size: #{data_compressed.size}&quot;</span>
<span class="ruby-comment">#=&gt; Compressed size: 887238</span>

<span class="ruby-identifier">uncompressed_data</span> = <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">Inflate</span>.<span class="ruby-identifier">inflate</span>(<span class="ruby-identifier">data_compressed</span>)

<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Uncompressed data is: #{uncompressed_data}&quot;</span>
<span class="ruby-comment">#=&gt; Uncompressed data is: The Project Gutenberg EBook of Don Quixote...</span>
</pre>

<h2 id="module-Zlib-label-Class+tree">Class tree<span><a href="#module-Zlib-label-Class+tree">&para;</a> <a href="#top">&uarr;</a></span></h2>
<ul><li>
<p><a href="Zlib/Deflate.html"><code>Zlib::Deflate</code></a></p>
</li><li>
<p><a href="Zlib/Inflate.html"><code>Zlib::Inflate</code></a></p>
</li><li>
<p><a href="Zlib/ZStream.html"><code>Zlib::ZStream</code></a></p>
</li><li>
<p><a href="Zlib/Error.html"><code>Zlib::Error</code></a></p>
<ul><li>
<p><a href="Zlib/StreamEnd.html"><code>Zlib::StreamEnd</code></a></p>
</li><li>
<p><a href="Zlib/NeedDict.html"><code>Zlib::NeedDict</code></a></p>
</li><li>
<p><a href="Zlib/DataError.html"><code>Zlib::DataError</code></a></p>
</li><li>
<p><a href="Zlib/StreamError.html"><code>Zlib::StreamError</code></a></p>
</li><li>
<p><a href="Zlib/MemError.html"><code>Zlib::MemError</code></a></p>
</li><li>
<p><a href="Zlib/BufError.html"><code>Zlib::BufError</code></a></p>
</li><li>
<p><a href="Zlib/VersionError.html"><code>Zlib::VersionError</code></a></p>
</li><li>
<p><a href="Zlib/InProgressError.html"><code>Zlib::InProgressError</code></a></p>
</li></ul>
</li></ul>

<p>(if you have GZIP_SUPPORT)</p>
<ul><li>
<p><a href="Zlib/GzipReader.html"><code>Zlib::GzipReader</code></a></p>
</li><li>
<p><a href="Zlib/GzipWriter.html"><code>Zlib::GzipWriter</code></a></p>
</li><li>
<p><a href="Zlib/GzipFile.html"><code>Zlib::GzipFile</code></a></p>
</li><li>
<p><a href="Zlib/GzipFile/Error.html"><code>Zlib::GzipFile::Error</code></a></p>
<ul><li>
<p><a href="Zlib/GzipFile/LengthError.html"><code>Zlib::GzipFile::LengthError</code></a></p>
</li><li>
<p><a href="Zlib/GzipFile/CRCError.html"><code>Zlib::GzipFile::CRCError</code></a></p>
</li><li>
<p><a href="Zlib/GzipFile/NoFooter.html"><code>Zlib::GzipFile::NoFooter</code></a></p>
</li></ul>
</li></ul>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="ASCII">ASCII
          <dd><p>Represents text data as guessed by deflate.</p>

<p>NOTE: The underlying constant Z_ASCII was deprecated in favor of Z_TEXT in zlib 1.2.2.  New applications should not use this constant.</p>

<p>See <a href="Zlib/ZStream.html#method-i-data_type"><code>Zlib::Deflate#data_type</code></a>.</p>
          <dt id="BEST_COMPRESSION">BEST_COMPRESSION
          <dd><p>Slowest compression level, but with the best space savings.</p>
          <dt id="BEST_SPEED">BEST_SPEED
          <dd><p>Fastest compression level, but with the lowest space savings.</p>
          <dt id="BINARY">BINARY
          <dd><p>Represents binary data as guessed by deflate.</p>

<p>See <a href="Zlib/ZStream.html#method-i-data_type"><code>Zlib::Deflate#data_type</code></a>.</p>
          <dt id="DEFAULT_COMPRESSION">DEFAULT_COMPRESSION
          <dd><p>Default compression level which is a good trade-off between space and time</p>
          <dt id="DEFAULT_STRATEGY">DEFAULT_STRATEGY
          <dd><p>Default deflate strategy which is used for normal data.</p>
          <dt id="DEF_MEM_LEVEL">DEF_MEM_LEVEL
          <dd><p>The default memory level for allocating zlib deflate compression state.</p>
          <dt id="FILTERED">FILTERED
          <dd><p><a href="Zlib/Deflate.html"><code>Deflate</code></a> strategy for data produced by a filter (or predictor). The effect of <a href="Zlib.html#FILTERED"><code>FILTERED</code></a> is to force more Huffman codes and less string matching; it is somewhat intermediate between <a href="Zlib.html#DEFAULT_STRATEGY"><code>DEFAULT_STRATEGY</code></a> and <a href="Zlib.html#HUFFMAN_ONLY"><code>HUFFMAN_ONLY</code></a>. Filtered data consists mostly of small values with a somewhat random distribution.</p>
          <dt id="FINISH">FINISH
          <dd><p>Processes all pending input and flushes pending output.</p>
          <dt id="FIXED">FIXED
          <dd><p><a href="Zlib/Deflate.html"><code>Deflate</code></a> strategy which prevents the use of dynamic Huffman codes, allowing for a simpler decoder for specialized applications.</p>
          <dt id="FULL_FLUSH">FULL_FLUSH
          <dd><p>Flushes all output as with <a href="Zlib.html#SYNC_FLUSH"><code>SYNC_FLUSH</code></a>, and the compression state is reset so that decompression can restart from this point if previous compressed data has been damaged or if random access is desired. Like <a href="Zlib.html#SYNC_FLUSH"><code>SYNC_FLUSH</code></a>, using <a href="Zlib.html#FULL_FLUSH"><code>FULL_FLUSH</code></a> too often can seriously degrade compression.</p>
          <dt id="HUFFMAN_ONLY">HUFFMAN_ONLY
          <dd><p><a href="Zlib/Deflate.html"><code>Deflate</code></a> strategy which uses Huffman codes only (no string matching).</p>
          <dt id="MAX_MEM_LEVEL">MAX_MEM_LEVEL
          <dd><p>The maximum memory level for allocating zlib deflate compression state.</p>
          <dt id="MAX_WBITS">MAX_WBITS
          <dd><p>The maximum size of the zlib history buffer.  Note that zlib allows larger values to enable different inflate modes.  See <a href="Zlib/Inflate.html#method-c-new"><code>Zlib::Inflate.new</code></a> for details.</p>
          <dt id="NO_COMPRESSION">NO_COMPRESSION
          <dd><p>No compression, passes through data untouched.  Use this for appending pre-compressed data to a deflate stream.</p>
          <dt id="NO_FLUSH">NO_FLUSH
          <dd><p><a href="Zlib.html#NO_FLUSH"><code>NO_FLUSH</code></a> is the default flush method and allows deflate to decide how much data to accumulate before producing output in order to maximize compression.</p>
          <dt id="OS_AMIGA">OS_AMIGA
          <dd><p>OS code for Amiga hosts</p>
          <dt id="OS_ATARI">OS_ATARI
          <dd><p>OS code for Atari hosts</p>
          <dt id="OS_CODE">OS_CODE
          <dd><p>The OS code of current host</p>
          <dt id="OS_CPM">OS_CPM
          <dd><p>OS code for CP/M hosts</p>
          <dt id="OS_MACOS">OS_MACOS
          <dd><p>OS code for Mac OS hosts</p>
          <dt id="OS_MSDOS">OS_MSDOS
          <dd><p>OS code for MSDOS hosts</p>
          <dt id="OS_OS2">OS_OS2
          <dd><p>OS code for OS2 hosts</p>
          <dt id="OS_QDOS">OS_QDOS
          <dd><p>OS code for QDOS hosts</p>
          <dt id="OS_RISCOS">OS_RISCOS
          <dd><p>OS code for RISC OS hosts</p>
          <dt id="OS_TOPS20">OS_TOPS20
          <dd><p>OS code for TOPS-20 hosts</p>
          <dt id="OS_UNIX">OS_UNIX
          <dd><p>OS code for UNIX hosts</p>
          <dt id="OS_UNKNOWN">OS_UNKNOWN
          <dd><p>OS code for unknown hosts</p>
          <dt id="OS_VMCMS">OS_VMCMS
          <dd><p>OS code for VM OS hosts</p>
          <dt id="OS_VMS">OS_VMS
          <dd><p>OS code for VMS hosts</p>
          <dt id="OS_WIN32">OS_WIN32
          <dd><p>OS code for Win32 hosts</p>
          <dt id="OS_ZSYSTEM">OS_ZSYSTEM
          <dd><p>OS code for Z-System hosts</p>
          <dt id="RLE">RLE
          <dd><p><a href="Zlib/Deflate.html"><code>Deflate</code></a> compression strategy designed to be almost as fast as <a href="Zlib.html#HUFFMAN_ONLY"><code>HUFFMAN_ONLY</code></a>, but give better compression for PNG image data.</p>
          <dt id="SYNC_FLUSH">SYNC_FLUSH
          <dd><p>The <a href="Zlib.html#SYNC_FLUSH"><code>SYNC_FLUSH</code></a> method flushes all pending output to the output buffer and the output is aligned on a byte boundary. Flushing may degrade compression so it should be used only when necessary, such as at a request or response boundary for a network stream.</p>
          <dt id="TEXT">TEXT
          <dd><p>Represents text data as guessed by deflate.</p>

<p>See <a href="Zlib/ZStream.html#method-i-data_type"><code>Zlib::Deflate#data_type</code></a>.</p>
          <dt id="UNKNOWN">UNKNOWN
          <dd><p>Represents an unknown data type as guessed by deflate.</p>

<p>See <a href="Zlib/ZStream.html#method-i-data_type"><code>Zlib::Deflate#data_type</code></a>.</p>
          <dt id="VERSION">VERSION
          <dd><p>The Ruby/zlib version string.</p>
          <dt id="ZLIB_VERSION">ZLIB_VERSION
          <dd><p>The string which represents the version of zlib.h</p>
        </dl>
        </section>



                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-adler32" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          adler32(string, adler)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Calculates Adler-32 checksum for <code>string</code>, and returns updated value of <code>adler</code>. If <code>string</code> is omitted, it returns the Adler-32 initial value. If <code>adler</code> is omitted, it assumes that the initial value is given to <code>adler</code>. If <code>string</code> is an IO instance, reads from the IO until the IO returns nil and returns Adler-32 of all read data.</p>

<p>Example usage:</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&quot;zlib&quot;</span>

<span class="ruby-identifier">data</span> = <span class="ruby-string">&quot;foo&quot;</span>
<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Adler32 checksum: #{Zlib.adler32(data).to_s(16)}&quot;</span>
<span class="ruby-comment">#=&gt; Adler32 checksum: 2820145</span>
</pre>

                              <div class="method-source-code" id="adler32-source">
            <pre>static VALUE
rb_zlib_adler32(int argc, VALUE *argv, VALUE klass)
{
    return do_checksum(argc, argv, adler32);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-adler32_combine" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          adler32_combine(adler1, adler2, len2)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Combine two Adler-32 check values in to one.  <code>adler1</code> is the first Adler-32 value, <code>adler2</code> is the second Adler-32 value.  <code>len2</code> is the length of the string used to generate <code>adler2</code>.</p>

                              <div class="method-source-code" id="adler32_combine-source">
            <pre>static VALUE
rb_zlib_adler32_combine(VALUE klass, VALUE adler1, VALUE adler2, VALUE len2)
{
    return ULONG2NUM(
        adler32_combine(NUM2ULONG(adler1), NUM2ULONG(adler2), NUM2LONG(len2)));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-crc32" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          crc32(string, crc)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Calculates CRC checksum for <code>string</code>, and returns updated value of <code>crc</code>. If <code>string</code> is omitted, it returns the CRC initial value. If <code>crc</code> is omitted, it assumes that the initial value is given to <code>crc</code>. If <code>string</code> is an IO instance, reads from the IO until the IO returns nil and returns CRC checksum of all read data.</p>

<p>FIXME: expression.</p>

                              <div class="method-source-code" id="crc32-source">
            <pre>static VALUE
rb_zlib_crc32(int argc, VALUE *argv, VALUE klass)
{
    return do_checksum(argc, argv, crc32);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-crc32_combine" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          crc32_combine(crc1, crc2, len2)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Combine two CRC-32 check values in to one.  <code>crc1</code> is the first CRC-32 value, <code>crc2</code> is the second CRC-32 value.  <code>len2</code> is the length of the string used to generate <code>crc2</code>.</p>

                              <div class="method-source-code" id="crc32_combine-source">
            <pre>static VALUE
rb_zlib_crc32_combine(VALUE klass, VALUE crc1, VALUE crc2, VALUE len2)
{
    return ULONG2NUM(
        crc32_combine(NUM2ULONG(crc1), NUM2ULONG(crc2), NUM2LONG(len2)));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-crc_table" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">crc_table</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the table for calculating CRC checksum as an array.</p>

                              <div class="method-source-code" id="crc_table-source">
            <pre>static VALUE
rb_zlib_crc_table(VALUE obj)
{
#if !defined(HAVE_TYPE_Z_CRC_T)
    /* z_crc_t is defined since zlib-1.2.7. */
    typedef unsigned long z_crc_t;
#endif
    const z_crc_t *crctbl;
    VALUE dst;
    int i;

    crctbl = get_crc_table();
    dst = rb_ary_new2(256);

    for (i = 0; i &lt; 256; i++) {
        rb_ary_push(dst, rb_uint2inum(crctbl[i]));
    }
    return dst;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-deflate" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          deflate(string[, level])
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          Zlib::Deflate.deflate(string[, level])
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Compresses the given <code>string</code>. Valid values of level are <a href="Zlib.html#NO_COMPRESSION"><code>Zlib::NO_COMPRESSION</code></a>, <a href="Zlib.html#BEST_SPEED"><code>Zlib::BEST_SPEED</code></a>, <a href="Zlib.html#BEST_COMPRESSION"><code>Zlib::BEST_COMPRESSION</code></a>, <a href="Zlib.html#DEFAULT_COMPRESSION"><code>Zlib::DEFAULT_COMPRESSION</code></a>, or an integer from 0 to 9.</p>

<p>This method is almost equivalent to the following code:</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">deflate</span>(<span class="ruby-identifier">string</span>, <span class="ruby-identifier">level</span>)
  <span class="ruby-identifier">z</span> = <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">Deflate</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">level</span>)
  <span class="ruby-identifier">dst</span> = <span class="ruby-identifier">z</span>.<span class="ruby-identifier">deflate</span>(<span class="ruby-identifier">string</span>, <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">FINISH</span>)
  <span class="ruby-identifier">z</span>.<span class="ruby-identifier">close</span>
  <span class="ruby-identifier">dst</span>
<span class="ruby-keyword">end</span>
</pre>

<p>See also <a href="Zlib.html#method-c-inflate"><code>Zlib.inflate</code></a></p>

                              <div class="method-source-code" id="deflate-source">
            <pre>static VALUE
rb_deflate_s_deflate(int argc, VALUE *argv, VALUE klass)
{
    struct zstream z;
    VALUE src, level, dst, args[2];
    int err, lev;

    rb_scan_args(argc, argv, &quot;11&quot;, &amp;src, &amp;level);

    lev = ARG_LEVEL(level);
    StringValue(src);
    zstream_init_deflate(&amp;z);
    err = deflateInit(&amp;z.stream, lev);
    if (err != Z_OK) {
        raise_zlib_error(err, z.stream.msg);
    }
    ZSTREAM_READY(&amp;z);

    args[0] = (VALUE)&amp;z;
    args[1] = src;
    dst = rb_ensure(deflate_run, (VALUE)args, zstream_ensure_end, (VALUE)&amp;z);

    return dst;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-gunzip" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          gunzip(src) &rarr; String
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Decode the given gzipped <code>string</code>.</p>

<p>This method is almost equivalent to the following code:</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">gunzip</span>(<span class="ruby-identifier">string</span>)
  <span class="ruby-identifier">sio</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">string</span>)
  <span class="ruby-identifier">gz</span> = <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipReader</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">sio</span>, <span class="ruby-value">encoding:</span> <span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">ASCII_8BIT</span>)
  <span class="ruby-identifier">gz</span>.<span class="ruby-identifier">read</span>
<span class="ruby-keyword">ensure</span>
  <span class="ruby-identifier">gz</span>&amp;.<span class="ruby-identifier">close</span>
<span class="ruby-keyword">end</span>
</pre>

<p>See also <a href="Zlib.html#method-c-gzip"><code>Zlib.gzip</code></a></p>

                              <div class="method-source-code" id="gunzip-source">
            <pre>static VALUE
zlib_gunzip(VALUE klass, VALUE src)
{
    struct gzfile gz0;
    struct gzfile *gz = &amp;gz0;
    int err;

    StringValue(src);

    gzfile_init(gz, &amp;inflate_funcs, zlib_gunzip_end);
    err = inflateInit2(&amp;gz-&gt;z.stream, -MAX_WBITS);
    if (err != Z_OK) {
        raise_zlib_error(err, gz-&gt;z.stream.msg);
    }
    gz-&gt;io = Qundef;
    gz-&gt;z.input = src;
    ZSTREAM_READY(&amp;gz-&gt;z);
    return rb_ensure(zlib_gunzip_run, (VALUE)gz, zlib_gzip_ensure, (VALUE)gz);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-gzip" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          gzip(src, level: nil, strategy: nil) &rarr; String
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Gzip the given <code>string</code>. Valid values of level are <a href="Zlib.html#NO_COMPRESSION"><code>Zlib::NO_COMPRESSION</code></a>, <a href="Zlib.html#BEST_SPEED"><code>Zlib::BEST_SPEED</code></a>, <a href="Zlib.html#BEST_COMPRESSION"><code>Zlib::BEST_COMPRESSION</code></a>, <a href="Zlib.html#DEFAULT_COMPRESSION"><code>Zlib::DEFAULT_COMPRESSION</code></a> (default), or an integer from 0 to 9.</p>

<p>This method is almost equivalent to the following code:</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">gzip</span>(<span class="ruby-identifier">string</span>, <span class="ruby-value">level:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">strategy:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">sio</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">sio</span>.<span class="ruby-identifier">binmode</span>
  <span class="ruby-identifier">gz</span> = <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipWriter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">sio</span>, <span class="ruby-identifier">level</span>, <span class="ruby-identifier">strategy</span>)
  <span class="ruby-identifier">gz</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">string</span>)
  <span class="ruby-identifier">gz</span>.<span class="ruby-identifier">close</span>
  <span class="ruby-identifier">sio</span>.<span class="ruby-identifier">string</span>
<span class="ruby-keyword">end</span>
</pre>

<p>See also <a href="Zlib.html#method-c-gunzip"><code>Zlib.gunzip</code></a></p>

                              <div class="method-source-code" id="gzip-source">
            <pre>static VALUE
zlib_s_gzip(int argc, VALUE *argv, VALUE klass)
{
    struct gzfile gz0;
    struct gzfile *gz = &amp;gz0;
    int err;
    VALUE src, opts, level=Qnil, strategy=Qnil, args[2];

    if (OPTHASH_GIVEN_P(opts)) {
        ID keyword_ids[2];
        VALUE kwargs[2];
        keyword_ids[0] = id_level;
        keyword_ids[1] = id_strategy;
        rb_get_kwargs(opts, keyword_ids, 0, 2, kwargs);
        if (kwargs[0] != Qundef) {
            level = kwargs[0];
        }
        if (kwargs[1] != Qundef) {
            strategy = kwargs[1];
        }
    }
    rb_scan_args(argc, argv, &quot;10&quot;, &amp;src);
    StringValue(src);
    gzfile_init(gz, &amp;deflate_funcs, zlib_gzip_end);
    gz-&gt;level = ARG_LEVEL(level);
    err = deflateInit2(&amp;gz-&gt;z.stream, gz-&gt;level, Z_DEFLATED,
                       -MAX_WBITS, DEF_MEM_LEVEL, ARG_STRATEGY(strategy));
    if (err != Z_OK) {
        zlib_gzip_end(gz);
        raise_zlib_error(err, gz-&gt;z.stream.msg);
    }
    ZSTREAM_READY(&amp;gz-&gt;z);
    args[0] = (VALUE)gz;
    args[1] = src;
    return rb_ensure(zlib_gzip_run, (VALUE)args, zlib_gzip_ensure, (VALUE)gz);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-inflate" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          inflate(string)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          Zlib::Inflate.inflate(string)
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Decompresses <code>string</code>. Raises a <a href="Zlib/NeedDict.html"><code>Zlib::NeedDict</code></a> exception if a preset dictionary is needed for decompression.</p>

<p>This method is almost equivalent to the following code:</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">inflate</span>(<span class="ruby-identifier">string</span>)
  <span class="ruby-identifier">zstream</span> = <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">Inflate</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">buf</span> = <span class="ruby-identifier">zstream</span>.<span class="ruby-identifier">inflate</span>(<span class="ruby-identifier">string</span>)
  <span class="ruby-identifier">zstream</span>.<span class="ruby-identifier">finish</span>
  <span class="ruby-identifier">zstream</span>.<span class="ruby-identifier">close</span>
  <span class="ruby-identifier">buf</span>
<span class="ruby-keyword">end</span>
</pre>

<p>See also <a href="Zlib.html#method-c-deflate"><code>Zlib.deflate</code></a></p>

                              <div class="method-source-code" id="inflate-source">
            <pre>static VALUE
rb_inflate_s_inflate(VALUE obj, VALUE src)
{
    struct zstream z;
    VALUE dst, args[2];
    int err;

    StringValue(src);
    zstream_init_inflate(&amp;z);
    err = inflateInit(&amp;z.stream);
    if (err != Z_OK) {
        raise_zlib_error(err, z.stream.msg);
    }
    ZSTREAM_READY(&amp;z);

    args[0] = (VALUE)&amp;z;
    args[1] = src;
    dst = rb_ensure(inflate_run, (VALUE)args, zstream_ensure_end, (VALUE)&amp;z);

    return dst;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-zlib_version" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">zlib_version</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the string which represents the version of zlib library.</p>

                              <div class="method-source-code" id="zlib_version-source">
            <pre>static VALUE
rb_zlib_version(VALUE klass)
{
    return rb_str_new2(zlibVersion());
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

